Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cppbinding] classParam<T> now keeps ownership of the shared_ptr for … #212

Merged
merged 3 commits into from
Dec 10, 2024

Conversation

3dJan
Copy link

@3dJan 3dJan commented Dec 4, 2024

…its own lifetime.

Without this change taking a shared_ptr from an API call and passing it to method using classParam causes a nullptr exception, because the shared_ptr would go out of scope to early.

One example is the lib3mf API for the volumetric extension Volumetric.cpp

Instead of having to create objects to keep the shared_ptr alive like

auto composeYZXInputX = composeYZX->GetInputX();
auto decomposePosOutputZ = decomposePos->GetOutputZ();
gyroidFunction->AddLink(decomposePosOutputZ, composeYZXInputX);

we would now be able to write

gyroidFunction->AddLink(decomposePos->GetOutputZ(),  composeYZX->GetInputX());

Copy link
Collaborator

@gangatp gangatp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@gangatp gangatp merged commit 06f9086 into Autodesk:develop Dec 10, 2024
13 checks passed
@3dJan 3dJan deleted the 3dJan/CppBindingsFixClassParam branch December 10, 2024 09:44
gangatp pushed a commit that referenced this pull request Dec 11, 2024
#212)

* [cppbinding] classParam<T> now keeps ownership of the shared_ptr for its own lifetime

* restore previous formatting of writeClassParamDefinition

* reducing white space changes to make the diff more comprehensive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants